#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#include<string.h>
#define  MA(x, y)  (x)*(y)

struct peo
{
    char name[10];
    int wage;
    int flowage;
    int maichu;
};
typedef struct peo peo;
int main()
{
    int N;
    scanf("%d", &N);
    peo peo[3];
    for (int i = 0; i < N; i++)
    {
        scanf("%s%d%d%d", peo[i].name, &peo[i].wage, &peo[i].flowage, &peo[i].maichu);

    }
    float arr[3];
    for (int i = 0; i < N; i++)
    {
        arr[i] = peo[i].wage + peo[i].flowage - peo[i].maichu;
    }
    for (int i = 0; i < N; i++)
    {
        printf("%s %.2f\n", peo[i].name, arr[i]);
    }

    return 0;
}
struct name
{
    char arr[80];
};
typedef struct name name;
int main16()
{
    int N;
    scanf("%d", &N);
    name name[5];
    for (int i = 0; i < 5; i++)
    {
        scanf("%s", name[i].arr);
    }
    char min[80];
    strcpy(min, name[0].arr);
    for (int i = 0; i < 5; i++)
    {
        if (strcmp(min, name[i].arr) > 0)
        {
            strcpy(min, name[i].arr);
        }
    }
    printf("Min is:%s", min);

}
int main15()
{
    int N;
    scanf("%d", &N);
    char arr[5];
    for (int i = 0; i < N; i++)
    {
        scanf("%s", arr[i]);
    }
    char min = arr[0];
    for (int i = 0; i < N; i++)
    {
        if (strcmp(min, arr[i]) > 0)
        {
            min = arr[i];
        }
    }
    printf("Min is: %s", min);
}

int fact(int i)
{
    if (i == 1)
        return 1;
    else
        return i * fact(i - 1);
}
int factadd(int N)
{
    int S = 0;
    for (int i = 1; i <= N; i++)
    {
        S += fact(i);
    }
    return S;
}
int main14()
{
    int N;
    scanf("%d", &N);
    int S = factadd(N);
    printf("%d", S);
    return 0;
}
int main13()
{
    float x;
    scanf("%f", &x);
    if (x < 15)
    {
        float y = 4 * x / 3;
        printf("%.2f", y);
    }
    else
    {
        float y = 2.5 * x - 17.5;
        printf("%.2f", y);
    }
    return 0;
}
int CountDigit(int number, int digit)
{
    int count = 0;
    if (number < 0)
    {
        number = -number;
    }
    while (number)
    {
        int a = number % 10;
        if (a == digit)
        {
            count++;
        }
        number = number / 10;
    }
    return count;
}
int main12()
{
    int number, digit;
    scanf("%d %d", &number, &digit);
    printf("Number of digit %d in %d: %d\n", digit, number, CountDigit(number, digit));

    return 0;
}
struct friend
{
    char name[10];
    int birthday;
    char id[17];
};
typedef struct friend friend;
int main11()
{
    int n = 0;
    scanf("%d", &n);
    friend arr[3];
    for (int i = 0; i < n; i++)
    {
        scanf("%s%d%s", arr[i].name, &arr[i].birthday, arr[i].id);
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n - i - 1; j++)
        {
            if (arr[j].birthday > arr[j + 1].birthday)
            {
                friend temp;
                temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        printf("%s %d %s\n", arr[i].name, arr[i].birthday, arr[i].id);
    }
    return 0;
}
int main10()
{
    int N, X;
    scanf("%d%d", &N,&X);
    int arr[5];
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &arr[i]);
    }
    int id = 0;
    int flag = 0;
    for (int i = 0; i < N; i++)
    {
        if (arr[i] == X)
        {
            flag = 1;
            id = i;
        }
    }
    if (flag == 1) {
        printf("%d", id);
    }
    else
        printf("Not Found");
    return 0;
}
int main9()
{
    int n = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            printf("%d*%d=%-4d", j, i, j * i);
        }
        printf("\n");
    }
    return 0;
}
int main8()
{
    int n = 0;
    scanf("%d", &n);
    if (n < 0)
    {
        printf("sign(%d) = -1", n);
    }
    else if (n > 0)
    {
        printf("sign(%d) = 1", n);
    }
    else
    {
        printf("sign(%d) = 0", n);
    }
    return 0;
}
double fact1(int n)
{
    if (n == 1)
        return 1;
    else
        return n * fact(n - 1);
}
double factsum(int n)
{
    double sum = 0;
    for (int i = 1; i <= n; i++)
    {
        sum += fact(i);
    }
    return sum;
}

int main7()
{
    int n;

    scanf("%d", &n);
    printf("fact(%d) = %.0f\n", n, fact(n));
    printf("sum = %.0f\n", factsum(n));

    return 0;
}

int main6()
{
    int i = 2;
    i = 3 / MA(i, i + 2) + 5;
    printf("%d\n", i);
    return 0;
}
struct Student
{
    int id;
    char name[20];
    int chinese;
    int math;
    int english;
};
int main5()
{
    typedef struct Student student;
    int n = 0;
    scanf("%d", &n);
    student arr[3];
    for (int i = 0; i < n; i++)
    {
        scanf("%d%s%d%d%d", &arr[i].id, arr[i].name, &arr[i].chinese, &arr[i].math, &arr[i].english);

    }
    float sum[3];
    float aver = 0;
    int aver_id = 0;
    for (int i = 0; i < n; i++)
    {
        sum[i] = arr[i].chinese + arr[i].math + arr[i].english;
        sum[i] = sum[i] / n * 1.0;
    }
    for (int i = 0; i < n; i++)
    {
        if (aver < sum[i])
        {
            aver_id = i;
            aver = sum[i];
        }
    }
    printf("num:%d,name:%s,average:%f",arr[aver_id].id,arr[aver_id].name,aver);
    return 0;
}
int main4()
{
    int arr[10];
    for (int i = 0; i < 10; i++)
    {
        scanf("%d", &arr[i]);
    }
    int max = arr[0];
    int id_max = 0;
    int min = arr[0];
    int id_min = 0;
    for (int i = 0; i < 10; i++)
    {
        if (arr[i] > max)
        {
            max = arr[i];
            id_max = i;
        }
        if (arr[i] < min)
        {
            min = arr[i];
            id_min = i;
        }
    }
    printf("min=%d,minpos=%d\n", min, id_min);
    printf("max=%d,maxpos=%d\n", max, id_max);
    return 0;
}
int main3()
{
    int n = 0;
    scanf("%d", &n);
    int count = 0;
    for (int i = 2; i < n; i++)
    {
        int flag = 0;
        for (int j = 2; j < i; j++)
        {
            if (i % j == 0)
            {
                flag = 1;
                break;
            }
        }
        if (flag == 0)
        {
            count++;
            printf("%6d", i);
            if (count % 10 == 0)
            {
                printf("\n");
            }
        }
    }
    return 0;
}
int main2()
{
    int month = 0;
    scanf("%d", &month);
    switch (month)
    {
    case 1:
        printf("January\n");
        break;
    case 2:
        printf("February\n");
        break;
    case 3:
        printf("March\n");
        break;
    case 4:
        printf("April\n");
        break;
    case 5:
        printf("May\n");
        break;
    case 6:
        printf("June\n");
        break;
    case 7:
        printf("July\n");
        break;
    case 8:
        printf("August\n");
        break;
    case 9:
        printf("September\n");
        break;
    case 10:
        printf("October\n");
        break;
    case 11:
        printf("November\n");
        break;
    case 12:
        printf("December\n");
        break;
    default:
        printf("None\n");
        break;
    }
    return 0;
}
double dist(double x1, double y1, double x2, double y2)
{
    double a = pow(pow(x1 - x2, 2) + pow(y1 - y2, 2), 0.5);
    return a;
}
int main1()
{

    double x1, y1, x2, y2;

    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("dist = %.2f\n", dist(x1, y1, x2, y2));

    return 0;
    
}